
package com.xifan.myaccount.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.xifan.myaccount.R;
import com.xifan.myaccount.entity.RecordType;

import java.util.List;

public class SearchListAdapter extends BaseAdapter {

    private List<RecordType> mTypeList;
    private Context mContext;

    public SearchListAdapter(Context context, List<RecordType> list) {
        mContext = context;
        mTypeList = list;
    }

    @Override
    public int getCount() {
        return mTypeList.size();
    }

    @Override
    public Object getItem(int position) {
        return mTypeList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View view, ViewGroup parent) {
        Holder holder;
        if (view == null) {
            holder = new Holder();
            view = View.inflate(mContext, R.layout.view_search_list_item, null);
            holder.typeName = (TextView) view.findViewById(R.id.type_name);
            view.setTag(holder);
        } else {
            holder = (Holder) view.getTag();
        }
        holder.typeName.setText(mTypeList.get(position).typeName);
        return view;
    }

    class Holder {
        TextView typeName;
    }

}
